/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.database;

import java.sql.CallableStatement;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;
import oracle.sql.ARRAY;
import oracle.sql.ArrayDescriptor;
import org.property.Estate;
import org.property.House;
import org.property.Sale;
import org.users.Agent;
import org.users.Customer;

/**
 *
 * @author Emre
 */
public class DatabaseYakup {

    private Connection connection = null;
    private String userName;
    private String password;
    private String portNumber;

    public DatabaseYakup() {
        userName = "user";
        password = "1234";
        portNumber = "1521";


    }

    public void connect() throws ClassNotFoundException, SQLException {

        Class.forName("oracle.jdbc.OracleDriver");
        System.out.println("Class Found");
        connection = DriverManager.getConnection("jdbc:oracle:thin:" + userName + "/" + password + "@localhost:" + portNumber + ":XE");
        System.out.println("connected !");

    }

    public void disconnect() throws SQLException {
        connection.close();
    }

    public void updateAgent(Agent selectedAgent) {
        try {
            //cust_id CHAR,v_name varchar2,v_surname varchar2,v_gsm_number char,v_e_mail varchar2, v_birth_date date,v_dist_id number,v_pro_id number,v_address_resume varchar2 ) IS 
            String updateAgent = "{ call UPDATE_AGENT(?, ?, ?,?, ?, ? ,?, ?, ?) }";
            CallableStatement cs = connection.prepareCall(updateAgent);
            cs.setString(1, selectedAgent.getTC_ID());
            cs.setString(2, selectedAgent.getName());
            cs.setString(3, selectedAgent.getSurname());
            cs.setString(4, selectedAgent.getGsmNumber());
            cs.setString(5, selectedAgent.geteMail());
            java.util.Date bd = new java.util.Date();

            bd = selectedAgent.getBirthDate();
            java.sql.Date sqlDate = new java.sql.Date(bd.getYear(), bd.getMonth(), bd.getDay());
            cs.setDate(6, sqlDate);
            cs.setInt(7, Integer.parseInt(selectedAgent.getAddressDistrict()));
            cs.setInt(8, Integer.parseInt(selectedAgent.getAddressProvince()));
            cs.setString(9, selectedAgent.getAddressResume());
            cs.execute();
        } catch (SQLException ex) {
            Logger.getLogger(DatabaseYakup.class.getName()).log(Level.SEVERE, null, ex);
        }


    }

    public void addEstate(Estate estate) {
        try {
            //       price NUMBER,v_type NUMBER,v_isconstruction char,v_iscountryside char,v_percept_of_construction number,v_img_array IMAGE_ARRAY,v_d_id number,v_p_id number,v_address varchar)

            ArrayDescriptor descriptor = ArrayDescriptor.createDescriptor("IMAGE_ARRAY", connection);
            String[] images = new String[estate.getImageList().size()];
            estate.getImageList().toArray(images);
            ARRAY imageArrayToPass = new ARRAY(descriptor, connection, images);
            String addEstate = "call ADD_ESTATE(?,?,?,?,?,?,?,?,?,? )";
            CallableStatement cs = connection.prepareCall(addEstate);
            cs.setInt(1, estate.getPrice());
            cs.setInt(2, Integer.parseInt(estate.getType()));
            String tmp;
            if (estate.getIsConstruction()) {
                tmp = "Y";
            } else {
                tmp = "N";
            }
            cs.setString(3, tmp);
            if (estate.getIsCountryside()) {
                tmp = "Y";
            } else {
                tmp = "N";
            }
            cs.setString(4, tmp);
            cs.setInt(5, estate.getPerceptOfConstruction());

            cs.setArray(6, imageArrayToPass);

            cs.setInt(7, Integer.parseInt(estate.getDistrict()));
            cs.setInt(8, Integer.parseInt(estate.getProvince()));
            cs.setString(9, estate.getAddress());
            cs.setString(10, estate.getDescription());
            cs.execute();
        } catch (SQLException ex) {
            Logger.getLogger(DatabaseYakup.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

    public LinkedList<Estate> getEstateList() throws SQLException {
        String query = "select estate_id,image_path,price,decode(type,1,'Satılık',2,'Kiralık') as type ,isConstruction,countryside,perceptofconstruction,district.name as d_name,province.name as p_name,address_resume,description from estate,district,province where sold <> 'Y' and district.d_id = estate.d_id and province.p_id = district.p_id";
        Statement statement = connection.createStatement();
        LinkedList<Estate> estates = new LinkedList<Estate>();
        LinkedList<String> images = new LinkedList<String>();
        ResultSet rs = statement.executeQuery(query);
        //ESTATE_ID IMAGE_PATH PRICE TYPE ISCONSTRUCTION COUNTRYSIDE PERCEPTOFCONSTRUCTION D_NAME P_NAME ADDRESS_RESUME DESCRIPTION 
        while (rs.next()) {

            rs.getString("IMAGE_PATH");
            rs.getInt("PRICE");
            rs.getString("TYPE");
            rs.getString("ISCONSTRUCTION");
            rs.getString("COUNTRYSIDE");
            rs.getInt("PERCEPTOFCONSTRUCTION");
            rs.getString("D_NAME");
            rs.getString("P_NAME");
            rs.getString("ADDRESS_RESUME");
            rs.getString("DESCRIPTION");
            boolean tmpcs, tmpcnt;
            if (rs.getString("ISCONSTRUCTION").equals("Y")) {
                tmpcs = true;
            } else {
                tmpcs = false;
            }
            if (rs.getString("COUNTRYSIDE").equals("Y")) {
                tmpcnt = true;
            } else {
                tmpcnt = false;
            }



            images = getEstateImagePathList(rs.getInt("ESTATE_ID"));
            //int id, String type, int price, boolean isConstruction, boolean isCountryside, int perceptOfConstruction,List<String> imageArray, String district, String province,  String address, String agentId, String customerId,String description

            estates.add(new Estate(rs.getInt("ESTATE_ID"), rs.getString("TYPE"), rs.getInt("PRICE"), tmpcnt, tmpcs, rs.getInt("PERCEPTOFCONSTRUCTION"), images, rs.getString("D_NAME"), rs.getString("P_NAME"), rs.getString("ADDRESS_RESUME"), "null", "null", rs.getString("DESCRIPTION")));

        }



        return estates;
    }

    private LinkedList<String> getEstateImagePathList(int id) throws SQLException {
        LinkedList<String> imageList = new LinkedList<String>();
        String query = "select image_paths.image_path from estate,image_paths,estate_images where estate.estate_id =? and estate.estate_id = estate_images.estate_id and image_paths.image_id = estate_images.image_id";
        PreparedStatement ps = connection.prepareStatement(query);
        ps.setInt(1, id);
        ResultSet rs = ps.executeQuery();
        while (rs.next()) {
            imageList.add(rs.getString("IMAGE_PATH"));

        }



        return imageList;

    }

    public void deleteEstate(Estate selectedEstate) {
        try {
            String deleteEstate = "call DELETE_ESTATE(?)";
            CallableStatement cs = connection.prepareCall(deleteEstate);
            cs.setInt(1, selectedEstate.getId());
            cs.execute();
        } catch (SQLException ex) {
            Logger.getLogger(DatabaseYakup.class.getName()).log(Level.SEVERE, null, ex);
        }

    }

    public void updateEstate(Estate estate) {
        try {
            String updateEstate = "call UPDATE_ESTATE(?,?,?,?,?,?,?,?,?,?)";
            //v_price NUMBER,v_type NUMBER,v_isconstruction char,v_iscountryside char,v_percept_of_construction number,v_d_id number,v_p_id number,v_address varchar,v_description varchar,v_id number)
            CallableStatement cs = connection.prepareCall(updateEstate);
            cs.setInt(1, estate.getPrice());
            cs.setInt(2, Integer.parseInt(estate.getType()));
            String tmp;
            if (estate.getIsConstruction()) {
                tmp = "Y";
            } else {
                tmp = "N";
            }
            cs.setString(3, tmp);
            if (estate.getIsCountryside()) {
                tmp = "Y";
            } else {
                tmp = "N";
            }
            cs.setString(4, tmp);
            cs.setInt(5, estate.getPerceptOfConstruction());



            cs.setInt(6, Integer.parseInt(estate.getDistrict()));
            cs.setInt(7, Integer.parseInt(estate.getProvince()));
            cs.setString(8, estate.getAddress());
            cs.setString(9, estate.getDescription());
            cs.setInt(10, estate.getId());
            cs.execute();




        } catch (SQLException ex) {
            Logger.getLogger(DatabaseYakup.class.getName()).log(Level.SEVERE, null, ex);
        }



    }

    public void sellEstate(Agent agent, String customerId, Estate estate) {
        try {
            String sellEstate = "call SELL_ESTATE(?,?)";
            CallableStatement cs = connection.prepareCall(sellEstate);
            cs.setString(1, agent.getTC_ID());
            cs.setString(2, customerId);
            cs.setInt(3, estate.getId());
            cs.execute();
        } catch (SQLException ex) {
            Logger.getLogger(DatabaseYakup.class.getName()).log(Level.SEVERE, null, ex);
        }

    }

    private LinkedList<String> getHouseImagePathList(int id) throws SQLException {
        LinkedList<String> imageList = new LinkedList<String>();
        String query = "select image_paths.image_path from house,image_paths,house_images where house.house_id =? and house.house_id = house_images.house_id and image_paths.image_id = house_images.image_id";
        PreparedStatement ps = connection.prepareStatement(query);
        ps.setInt(1, id);
        ResultSet rs = ps.executeQuery();
        while (rs.next()) {
            imageList.add(rs.getString("IMAGE_PATH"));

        }



        return imageList;

    }

    public Map<String, String> getRoomTypes() throws SQLException {
        String query = "select * from room_type";
        Map<String, String> roomTypeMap = new HashMap<String, String>();
        Statement stmt = connection.createStatement();
        ResultSet rs = stmt.executeQuery(query);
        while (rs.next()) {
            roomTypeMap.put(rs.getString("ROOM_TYPE"), Integer.toString(rs.getInt("ROOM_ID")));

        }

        return roomTypeMap;
    }

    public void addHouse(House house) throws SQLException {
//v_room_id number,v_price NUMBER,v_type NUMBER,v_description char,v_hascombi char,
//v_hasdooubleglazing char,v_hasbalcony char,v_hascabletv char,v_haselevator char,v_hasfirealarm char,
//v_haspark char,v_img_array IMAGE_ARRAY,v_d_id number, v_p_id number            
        ArrayDescriptor descriptor = ArrayDescriptor.createDescriptor("IMAGE_ARRAY", connection);
        String[] images = new String[house.getImageList().size()];
        house.getImageList().toArray(images);
        ARRAY imageArrayToPass = new ARRAY(descriptor, connection, images);
        String combi = house.isIsCombi() ? "y" : "n";
        String glazing = house.isIsDoubleGlazing() ? "y" : "n";
        String balcony = house.isIsBalcony() ? "y" : "n";
        String cabletv = house.isIsCableTV() ? "y" : "n";
        String elevator = house.isIsElevator() ? "y" : "n";
        String firealarm = house.isIsFireAlarm() ? "y" : "n";
        String park = house.isIsPark() ? "y" : "n";
        String sold = house.isIsSold() ? "y" : "n";
        int dId = Integer.parseInt(house.getDistrict());
        int pId = Integer.parseInt(house.getProvince());
        String addHouseStoredProcedure = "{ call ADD_HOUSE(?, ?, ?,?, ?, ? ,?, ?, ?,?,?,?,?,?) }";
        CallableStatement cs = connection.prepareCall(addHouseStoredProcedure);
        //java.sql.Date sqlDate = new java.sql.Date(date.getYear(), date.getMonth(), date.getDate());
        // sqlDate = (java.sql.Date)date;
        cs.setInt(1, Integer.parseInt(house.getRoom_type()));
        cs.setInt(2, house.getPrice());
        cs.setInt(3, Integer.parseInt(house.getType()));
        cs.setString(4, house.getDescription());
        cs.setString(5, combi);
        cs.setString(6, glazing);
        cs.setString(7, balcony);
        cs.setString(8, cabletv);
        cs.setString(9, elevator);
        cs.setString(10, firealarm);
        cs.setString(11, park);
        cs.setArray(12, imageArrayToPass);
        cs.setInt(13, dId);
        cs.setInt(14, pId);

        cs.execute();
    }

    public void updateHouse(House house) throws SQLException {
        ArrayDescriptor descriptor = ArrayDescriptor.createDescriptor("IMAGE_ARRAY", connection);
        //String[] images = new String[house.getImageList().size()];
        //house.getImageList().toArray(images);
        //ARRAY imageArrayToPass = new ARRAY(descriptor, connection, images);

        String addHouseStoredProcedure = "{ call UPDATE_HOUSE(?, ?, ?,?, ?, ? ,?, ?, ?,?,?,?,?,?) }";
        CallableStatement cs = connection.prepareCall(addHouseStoredProcedure);
        //java.sql.Date sqlDate = new java.sql.Date(date.getYear(), date.getMonth(), date.getDate());
        //sqlDate = (java.sql.Date)date;
        String combi = house.isIsCombi() ? "y" : "n";
        String glazing = house.isIsDoubleGlazing() ? "y" : "n";
        String balcony = house.isIsBalcony() ? "y" : "n";
        String cabletv = house.isIsCableTV() ? "y" : "n";
        String elevator = house.isIsElevator() ? "y" : "n";
        String firealarm = house.isIsFireAlarm() ? "y" : "n";
        String park = house.isIsPark() ? "y" : "n";

        cs.setInt(1, Integer.parseInt(house.getRoom_type()));
        cs.setInt(2, house.getPrice());
        cs.setInt(3, Integer.parseInt(house.getType()));
        cs.setString(4, house.getDescription());
        cs.setString(5, combi);
        cs.setString(6, glazing);
        cs.setString(7, balcony);
        cs.setString(8, cabletv);
        cs.setString(9, elevator);
        cs.setString(10, firealarm);
        cs.setString(11, park);
        cs.setInt(12, Integer.parseInt(house.getDistrict()));
        cs.setInt(13, Integer.parseInt(house.getProvince()));
        cs.setInt(14, house.getId());

        cs.execute();
    }
    
    
    public List<Sale> getDailySellList() throws SQLException{
        List<Sale> sales = new LinkedList<Sale>(); 
        Customer customer; 
        Agent agent ;
        String itemId;
                
        String query = "select house.*,decode(type,1,'Sale',2,'Rent') as types from house where sold ='Y' and trunc(sell_date) = trunc(sysdate)";
        Statement stmt = connection.createStatement();
        ResultSet rs = stmt.executeQuery(query);
        while(rs.next()){
            
            itemId = "H"+Integer.toString(rs.getInt("HOUSE_ID"));
            
            agent = new Agent();
            customer = new Customer();
            customer = getACustomer(rs.getString("CUSTOMER_TC_ID"));
            System.out.println(rs.getString("AGENT_TC_ID")+"----------");
            agent = getAnAgent(rs.getString("AGENT_TC_ID"));
            sales.add(new Sale(customer, agent, itemId, rs.getString("types")));
        }
        
        
           String query2 = "select estate.*,decode(type,1,'Sale',2,'Rent') as types from estate where sold ='Y' and trunc(sell_date) = trunc(sysdate)";
        Statement stmt2 = connection.createStatement();
        ResultSet rs2 = stmt2.executeQuery(query2);
        while(rs2.next()){
            
            itemId = "E"+Integer.toString(rs.getInt("ESTATE_ID"));
            
            agent = new Agent();
            customer = getACustomer(rs.getString("CUSTOMER_TC_ID"));
            agent = getAnAgent(rs.getString("AGENT_TC_ID"));
            sales.add(new Sale(customer, agent, itemId, rs.getString("types")));
        }
        
    
    
        return sales;
    }
    
    
    public Customer getACustomer(String ID){
        Customer customer = null;
        System.out.print(ID+"------------------");
        try {
            String query = "select person.*,customer.*, district.name as d_name, province.name as p_name  from customer,person,district  ,province  ";
                    query += "where (customer.isdeleted ='N' or customer.isdeleted ='n') and  person.tc_id = ? and person.tc_id = customer.customer_tc_id and district.d_id = person.d_id and province.p_id = person.p_id ";
                    PreparedStatement statement = connection.prepareStatement(query);
                    statement.setString(1, ID);
                    ResultSet rs = statement.executeQuery();
                    java.util.Date birthDate;
                    java.util.Date registerDate;
                    if  (rs.next()) {
                        birthDate = new Date(rs.getDate("BIRTH_DATE").getTime());
                        registerDate = new Date(rs.getDate("ADDINGTIME").getTime());
                        customer = new Customer(rs.getString("TC_ID"), rs.getString("name"), rs.getString("surname"), rs.getString("GSM_NUMBER"), rs.getString("E_MAIL"), birthDate, rs.getString("D_NAME"), rs.getString("ADDRESS_RESUME"), rs.getString("P_NAME"), registerDate);

                    }
                    
        }
     
        catch (SQLException ex) {
            Logger.getLogger(DatabaseYakup.class.getName()).log(Level.SEVERE, null, ex);
        }
    
       return  customer;
    
    
    }
    
    
    
    public Agent getAnAgent(String ID){
        Agent agent =null;
        try {
            
            String query = "SELECT person.*,agent.*,province.name as p_name, district.name as d_name FROM PERSON,AGENT,DISTRICT,PROVINCE WHERE PERSON.TC_ID = ? and AGENT.AGENT_TC_ID = PERSON.TC_ID AND PERSON.D_ID = DISTRICT.D_ID and PERSON.P_ID = PROVINCE.P_ID ";
            PreparedStatement statement = connection.prepareStatement(query);
            statement.setString(1, ID);
            ResultSet rs = statement.executeQuery();
            if(rs.next()){
                java.util.Date birthDate = (java.util.Date) rs.getDate("BIRTH_DATE");
                agent = new Agent(rs.getString("USER_NAME"),rs.getString("PASSWORD"),rs.getString("TC_ID"),rs.getString("NAME"),rs.getString("SURNAME"),rs.getString("GSM_NUMBER"),rs.getString("E_MAIL"),birthDate,rs.getString("D_NAME"),rs.getString("ADDRESS_RESUME"),rs.getString("P_NAME"));
            
            }
            
            
            
        } catch (SQLException ex) {
            Logger.getLogger(DatabaseYakup.class.getName()).log(Level.SEVERE, null, ex);
        }
        return agent;
    
    }
 }



    //rty
//       public List<House> getHouseList() throws SQLException {
//        List<House> houseList = new ArrayList<House>();
//        String query = "select h.HOUSE_ID,r.ROOM_TYPE,h.TYPE,h.CUSTOMER_TC_ID,h.PRICE,h.DESCRIPTION,h.HASCOMBI,h.HASDOUBLEGLAZING,";
//        query += "h.HASBALCONY,h.HASCABLETV,h.HASELEVATOR,h.HASFIREALARM,h.HASPARK,h.SOLD,h.AGENT_TC_ID,h.SELL_DATE,p.NAME as pname,d.NAME as dname from house h ";
//        query += "left join room_type r on  h.room_Id=r.room_Id ";
//        query += "inner join province p on h.p_Id=p.p_Id ";
//        query += "inner join district d on h.d_Id=d.d_Id";
//        Statement statement = connection.prepareStatement(query);
//        ResultSet rs = statement.executeQuery(query);
//        LinkedList<String> imageLinkedList = new LinkedList<String>();
//        while (rs.next()) {
//
//            java.util.Date sellDate = rs.getDate("SELL_DATE");
//            imageLinkedList = getHouseImagePathList(rs.getInt("HOUSE_ID"));
//            houseList.add(new House(rs.getInt("HOUSE_ID"), rs.getString("ROOM_TYPE"), rs.getInt("PRICE"), rs.getInt("TYPE"),
//                    rs.getString("CUSTOMER_TC_ID"), rs.getString("HASCOMBI").charAt(0),
//                    rs.getString("HASDOUBLEGLAZING").charAt(0), rs.getString("HASBALCONY").charAt(0),
//                    rs.getString("HASCABLETV").charAt(0), rs.getString("HASELEVATOR").charAt(0),
//                    rs.getString("HASFIREALARM").charAt(0), rs.getString("HASPARK").charAt(0),
//                    rs.getString("SOLD").charAt(0), rs.getString("AGENT_TC_ID"), sellDate, rs.getString("pname"), rs.getString("dname"), rs.getString("DESCRIPTION")));
//        }
//        return houseList;
//    }  
//     public List<Customer> getCustomerList(){
//         List<Customer> customerList = new LinkedList<Customer>();
//        try {
//            
//            String query = "select person.*,customer.*, district.name as d_name, province.name as p_name  from customer,person,district  ,province  ";
//            query+=        "where customer.isdeleted ='N' and person.tc_id = customer.customer_tc_id and district.d_id = person.d_id and province.p_id = person.p_id ";
//            Statement statement = connection.createStatement();
//            ResultSet rs = statement.executeQuery(query);
//            java.util.Date birthDate ;
//            java.util.Date registerDate;
//            while(rs.next()){
//                birthDate = new Date(rs.getDate("BIRTH_DATE").getTime());
//                registerDate = new Date(rs.getDate("ADDINGTIME").getTime());
//                customerList.add(new Customer(rs.getString("TC_ID"), rs.getString("name"), rs.getString("surname"),rs.getString("GSM_NUMBER"), rs.getString("E_MAIL"),birthDate ,rs.getString("D_NAME") , rs.getString("ADDRESS_RESUME"), rs.getString("P_NAME"), registerDate));
//            
//            }
//            
//        } catch (SQLException ex) {
//            Logger.getLogger(DatabaseYakup.class.getName()).log(Level.SEVERE, null, ex);
//        }
//     
//        return customerList;
//     
//     
//     
//     }  




   //rty
        //       public List<House> getHouseList() throws SQLException {
        //        List<House> houseList = new ArrayList<House>();
        //        String query = "select h.HOUSE_ID,r.ROOM_TYPE,h.TYPE,h.CUSTOMER_TC_ID,h.PRICE,h.DESCRIPTION,h.HASCOMBI,h.HASDOUBLEGLAZING,";
        //        query += "h.HASBALCONY,h.HASCABLETV,h.HASELEVATOR,h.HASFIREALARM,h.HASPARK,h.SOLD,h.AGENT_TC_ID,h.SELL_DATE,p.NAME as pname,d.NAME as dname from house h ";
        //        query += "left join room_type r on  h.room_Id=r.room_Id ";
        //        query += "inner join province p on h.p_Id=p.p_Id ";
        //        query += "inner join district d on h.d_Id=d.d_Id";
        //        Statement statement = connection.prepareStatement(query);
        //        ResultSet rs = statement.executeQuery(query);
        //        LinkedList<String> imageLinkedList = new LinkedList<String>();
        //        while (rs.next()) {
        //
        //            java.util.Date sellDate = rs.getDate("SELL_DATE");
        //            imageLinkedList = getHouseImagePathList(rs.getInt("HOUSE_ID"));
        //            houseList.add(new House(rs.getInt("HOUSE_ID"), rs.getString("ROOM_TYPE"), rs.getInt("PRICE"), rs.getInt("TYPE"),
        //                    rs.getString("CUSTOMER_TC_ID"), rs.getString("HASCOMBI").charAt(0),
        //                    rs.getString("HASDOUBLEGLAZING").charAt(0), rs.getString("HASBALCONY").charAt(0),
        //                    rs.getString("HASCABLETV").charAt(0), rs.getString("HASELEVATOR").charAt(0),
        //                    rs.getString("HASFIREALARM").charAt(0), rs.getString("HASPARK").charAt(0),
        //                    rs.getString("SOLD").charAt(0), rs.getString("AGENT_TC_ID"), sellDate, rs.getString("pname"), rs.getString("dname"), rs.getString("DESCRIPTION")));
        //        }
        //        return houseList;
        //    }
        //     public List<Customer> getCustomerList(){
        //         List<Customer> customerList = new LinkedList<Customer>();
        //        try {
        //
        //            String query = "select person.*,customer.*, district.name as d_name, province.name as p_name  from customer,person,district  ,province  ";
        //            query+=        "where customer.isdeleted ='N' and person.tc_id = customer.customer_tc_id and district.d_id = person.d_id and province.p_id = person.p_id ";
        //            Statement statement = connection.createStatement();
        //            ResultSet rs = statement.executeQuery(query);
        //            java.util.Date birthDate ;
        //            java.util.Date registerDate;
        //            while(rs.next()){
        //                birthDate = new Date(rs.getDate("BIRTH_DATE").getTime());
        //                registerDate = new Date(rs.getDate("ADDINGTIME").getTime());
        //                customerList.add(new Customer(rs.getString("TC_ID"), rs.getString("name"), rs.getString("surname"),rs.getString("GSM_NUMBER"), rs.getString("E_MAIL"),birthDate ,rs.getString("D_NAME") , rs.getString("ADDRESS_RESUME"), rs.getString("P_NAME"), registerDate));
        //
        //            }
        //
        //        } catch (SQLException ex) {
        //            Logger.getLogger(DatabaseYakup.class.getName()).log(Level.SEVERE, null, ex);
        //        }
        //
        //        return customerList;
        //
        //
        //
        //     }